<template>
  <div class="my-input-number-wrap">
    <span class="left" @click="sub">-</span>
    <div>
      <input v-model=a class="my-input" placeholder="请输入内容"  />
    </div>
    <span class="right" @click="add" >+</span>
  </div>
</template>

<script>
export default {
  name: "MyInput",
  props: {},
  data() {
    return {
      a:''
    };
  },
  methods: {
    sub(){
      this.a=this.a-1
      this.$emit("change",this.a)
    },
    add(){
      this.a=parseInt(this.a)+1
      this.$emit("change",this.a)
    }
  },
};
</script>

<style scoped>
.my-input-number-wrap {
  /* 使容器内的元素居中 */
  position: relative;
  align-items: center;
  display: flex;
}
.my-input {
  /* 设置输入框的padding */
  width: 100px;
  padding: 10px;
  box-sizing: border-box;
  height: 40px;
  /* 去除输入框的边框 */
  outline: none;
  /* 设置输入框的边框颜色 */
  border: 1px solid #dcdfe6;
  text-align: center;
}
.iconfont {
  /* 设置图标的位置和颜色 */
  position: absolute;
  color: rgb(194, 192, 192);
  font-size: 15px;
  /* 右下角的位置 */
  right: 10px;
  top: 3px;
  /* 使图标可点击 */
  cursor: pointer;
}
.left,
.right {
  border: 1px solid #dcdfe6;
  box-sizing: border-box;
  height: 40px;
  line-height: 40px;
  width: 40px;
  text-align: center;
  border-right: 0;
  background: #f5f7fa;
  cursor: pointer;
}
.right {
  border: 1px solid #dcdfe6;
  border-left: 0;
}
</style>